#ifndef __APP_DEV_CONFIG_H
#define __APP_DEV_CONFIG_H

#include "app_config.h"

#define MAGIC_WORD 0xEB90EB90

////远程服务器IP地址端口号
//typedef struct remote_server_config
//{
//	rt_uint32_t magic_word;
//	char  			ip[20];//ip地址
//	rt_uint32_t port;//端口号 
//}remote_server_config;

//MODBUS服务器IP地址端口号
typedef struct modbus_tcp_config
{
	rt_uint32_t magic_word;
	rt_uint32_t slave_id;
	char  			ip[20];//ip地址
	rt_uint32_t port;//端口号 
}modbus_tcp_config;

typedef struct modbus_rtu_config
{
	rt_uint32_t magic_word;
	rt_uint32_t slave_id;
	rt_uint32_t baud;
}modbus_rtu_config;


//LAN口IP地址端、口号、网关、子网掩码
typedef struct lan_config
{
	rt_uint32_t magic_word;
	rt_uint32_t port;//端口号 
	char  ip[20];//ip地址
	char  gateway[20];//网关
	char  subnet[20];//子网掩码
}lan_config;

typedef struct net_config
{
	rt_uint32_t magic_word;
	rt_uint8_t  wifi_enable;
	rt_uint8_t 	lte_enable;
	rt_uint8_t  prt_net;
	char ssid[100];
	char pwd[100];
}net_config;

//校准信息-电压
typedef struct cal_voltage_info
{
	rt_uint32_t magic_word;
	rt_uint32_t voltage_A;
	rt_uint32_t voltage_B;
	rt_uint32_t voltage_C;
}cal_voltage_info;

//校准信息-电流增益
typedef struct gain_current_info
{
	rt_uint32_t magic_word;
	rt_uint32_t gain_current_A;
//	rt_uint32_t gain_current_B;
//	rt_uint32_t gain_current_C;
}gain_current_info;

//校准信息-电流偏置
typedef struct offset_current_info
{
	rt_uint32_t magic_word;
	rt_uint32_t offset_current_A;
//	rt_uint32_t offset_current_B;
//	rt_uint32_t offset_current_C;	
}offset_current_info;

typedef struct dev_config//设备参数
{
	//char 											dev_id[10];
	lan_config								lan;
	modbus_tcp_config					modbus_tcp;
	modbus_rtu_config					modbus_rtu;
	net_config								net;
	cal_voltage_info					vol_gain;
	gain_current_info					cur_gain;
	offset_current_info			  cur_offset;
}dev_config;




#define LAN_INFO_SIZE     			 sizeof(struct lan_config)
#define MODBUS_TCP_INFO_SIZE  	 sizeof(struct modbus_tcp_config)
#define MODBUS_RTU_INFO_SIZE  	 sizeof(struct modbus_rtu_config)
#define MODBUS_NET_INFO_SIZE  	 sizeof(struct net_config)	
#define VOL_GAIN_INFO_SIZE			 sizeof(cal_voltage_info)
#define CUR_GAIN_INFO_SIZE			 sizeof(gain_current_info)
#define VOL_OFFSET_INFO_SIZE		 sizeof(offset_current_info)

int check_lan_config_data(lan_config lan); 
int check_modbus_server_config_data(modbus_tcp_config data);
void read_dev_config(void);

#endif

